# for循环用于遍历任何序列的项目，如：列表、元组、字符串等
# for循环的一个重要特点是它可以遍历任何可迭代对象
def for_bianli_range():
    # 使用range()函数创建一个列表：range(start, stop, step)函数用于生成一个数字序列，用于控制循环次数
    for i in range(5):
        print(i)
    print('-----打印0-4结束！-------')
    for i in range(1, 5):
        print(i)
    print('-----打印1-4结束！-------')
    for i in range(2, 20, 2):
        print(i)
    print('-----打印2-20(不包含20)中间的偶数-结束！-------')
# 遍历字符串
def for_bianli_str():
    str = 'cendy'
    for i in str:
        print(i)
    print('-----遍历str字符串结束！-------')
# 遍历列表
def for_bianli_list():
    my_list = ['cendy', 'apple', 'orange']
    for i in my_list:
        print(i)
    print('-----遍历my_list列表结束！-------')
# 遍历列表-使用enumerate()函数返回索引和值
def for_bianli_list_enumerate():
    my_list = ['cendy', 'apple', 'orange']
    for index,value in enumerate(my_list):
        print(index,value)
# 遍历列表-使用zip()函数同时遍历多个列表
def for_bianli_list_zip():
    names = ["Alice", "Bob", "Charlie"]
    ages = [25, 30, 35, 40]
    addresses = ["New York", "Paris", "Tokyo", "Sydney", "Beijing"]
    for name,age,addr in zip(names,ages,addresses):
        # print(name,age,addr)
        print(f'{name} is {age} years old,address is {addr}')
# 判断输入的内容是否为纯数字
def judge_num():
    str = input("请输入一个数字：")
    is_number = '是'
    for i in str:
        if i not in '0123456789':
            is_number = '不是'
            break
        # else:
            # is_number = '是'
    print(f'{str}{is_number}一个数字')



if __name__ == '__main__':
    # for_bianli_range()
    # for_bianli_str()
    # judge_num()
    # for_bianli_list()
    # for_bianli_list_enumerate()
    for_bianli_list_zip()